<?php
//服务
namespace App\Http\Controllers\Web;

use App\Http\Controllers\Controller;
use App\Models\ShopPermission;
use Illuminate\Support\Facades\Validator;

class PermissionController extends Controller
{

    public function all(){
        $permissions = ShopPermission::paginate(10);
        return show(200,'ok',$permissions);
    }

    public function store(){
        $rules = [
            'name'=>'required|min:3',
            'description'=>'required'
        ];
        $validator = Validator::make(request(), $rules);
        if ($validator->fails()) {
            return show(201,$validator->errors()->first());
        }

        ShopPermission::create(request(['name','description']));
        return show(200,'save successfully');
    }
}
